package com.vlada.studzad.pages;

import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry5.annotations.ApplicationState;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.grid.GridDataSource;

import com.vlada.studzad.data.MockDataStudentSource;
import com.vlada.studzad.model.Privilege;
import com.vlada.studzad.model.User;
import com.vlada.studzad.model.Student;
import com.vlada.studzad.util.StudentSource;

public class PreviewStudentsProfiles {
	
	@ApplicationState
	@Property
	private User user;
	private boolean userExists;

	@ApplicationState
	private MockDataStudentSource students;
	private Student student;
	
	Object onActivate() {
		if (!userExists)return Index.class;
		else if(user.getPrivilege()==Privilege.ADMINISTRATOR){
			return null;
		}
		return Index.class;
	}
	
	public List<Student> getAllStudents() {
		return students.getAllStudents();
	}
	
	public void setStudent(Student student) {
		this.student = student;
	}

	public Student getStudent() {
		return student;
	}

	public GridDataSource getStudentSource() {
		return new StudentSource(students);
	}
	
}
